Tomáš Pospíšek's Notizblock

Writing into STDIN of an already running process

I have the following problem: I started a fsck. It ran for a few hours. And now I notice, that I forgot to give it the "-y" option. Now fsck is asking me the same yes/no question a million times for each broken block again and is expecting me to type "y" a million times. What to do?

# pgrep fsck
6503
# while true; do echo "j"; sleep 0.1; done | script -q -c "reptyr 6503" /dev/null

Explanation:

So finally we can answer one million times "j" to fsck which is waiting for our answer...

It's amazing that one is able to re-steal the tty from reptyr itself again. Once my solution with yes got stuck, I fixed it with the echo; sleep loop and reptyr'ed.

That's a sign of a well though out and cleanly executed abstract idea.

Tomáš Pospíšek, 2015-05-25

Articles